Skip to content

Conversation

@mcfnord
Copy link
Contributor

@mcfnord mcfnord commented Jan 8, 2026

feat(server): Add CentralDefense for ASN/CIDR blocking

This introduces the CentralDefense module, a server-side security mechanism designed to reject connections from specific Autonomous Systems (ASNs) and IP ranges (CIDRs). This allows a central service to filter out traffic from known abuse sources.

Key Implementation Details:

  1. synchronous "Bouncer" Logic:

    • Hooks into CServer::OnNewConnection immediately after the mutex lock.
    • Uses Qt::DirectConnection to ensure the block check completes synchronously.
    • If a client is blocked, the connection is dropped before the server sends the "Welcome" message or updates the connected client list.
  2. API Protection & Throttling:

    • Integrates with ip-api.com for ASN lookups but implements aggressive protection for the API provider.
    • Memory-First: Checks a local RAM cache and static CIDR list before attempting any network lookup.
    • Queuing: Limits concurrent requests to prevent bursts.
    • Throttling: Enforces a delay between outbound requests to respect API rate limits.
    • Negative Caching: Caches lookup results (allow or deny) to ensure subsequent connections from the same IP require zero network traffic.
  3. Configuration:

    • Fetches a remote blocklist (ASN/CIDR format) on startup and refreshes periodically.
    • Parses blocklist entries robustly, ignoring comments and descriptive text.

Checklist

  • I've verified that this Pull Request follows the general code principles
  • I tested my code and it does what I want
  • My code follows the style guide
  • I waited some time after this Pull Request was opened and all GitHub checks completed without errors.
  • I've filled all the content above

@ann0see
Copy link
Member

ann0see commented Jan 10, 2026

Thanks!

ip-api.com

I'd prefer not to hardcode services.

Copy link
Member

@ann0see ann0see left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very interesting! Thank you.
I believe that we'll have a long discussion here...

emit updated(m_blockedAsns.size(), m_blockedCidrs.size());
}

bool CentralDefense::tryParseIpv4CidrLine(const QString& line, Ipv4Cidr& outCidr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should write the code generic such that it supports ipv6 too

@stefan1000
Copy link

I’m concerned about moving network defense into an audio application, especially via a centralized blocklist. Beyond the performance overhead, this creates a central point of failure and raises privacy issues by sending client IPs to external APIs (once again).

These 'wrecking ball' blocks (ASN/CIDR) risk significant collateral damage and are more precisely managed at the firewall level. Furthermore, the governance of a central 'bad actor' list is an unsolvable problem for a decentralized project—it creates a gatekeeper role that doesn't belong in the Jamulus audio engine.

@softins
Copy link
Member

softins commented Jan 17, 2026

I’m concerned about moving network defense into an audio application, especially via a centralized blocklist. Beyond the performance overhead, this creates a central point of failure and raises privacy issues by sending client IPs to external APIs (once again).

These 'wrecking ball' blocks (ASN/CIDR) risk significant collateral damage and are more precisely managed at the firewall level. Furthermore, the governance of a central 'bad actor' list is an unsolvable problem for a decentralized project—it creates a gatekeeper role that doesn't belong in the Jamulus audio engine.

I would agree. While anyone is free to create their own fork with modifications to support their use case, I'm not convinced this kind of functionality belongs within Jamulus itself.



// --- Central Defense Integration ---
m_centralDefense = new CentralDefense(QUrl("https://jamulus.live/asn-ip-client-blocks.txt"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha! This would explain why Jamulus Explorer is no longer able to display City, Version, OS and connected clients for the "Duet" server that exists in each genre:

Image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. There's a script version and a binary version, and the binary version is doing that (which is a bug).

@ann0see
Copy link
Member

ann0see commented Jan 18, 2026

the governance of a central 'bad actor' list is an unsolvable problem for a decentralized project—it creates a gatekeeper role that doesn't belong in the Jamulus audio engine.

While this is true, we should still think about:

  1. How can server admins protect their server from bad actors? There could be valid reasons for this.
  2. Server admins should be able to protect themselves from known bad actors - E-Mail servers for example have shared (configurable) blacklists.
  3. Can users themselves be enabled to block (?) bad actors? Potentially just for themselves?

@rdica
Copy link
Contributor

rdica commented Jan 21, 2026

the governance of a central 'bad actor' list is an unsolvable problem for a decentralized project—it creates a gatekeeper role that doesn't belong in the Jamulus audio engine.

While this is true, we should still think about:

  1. How can server admins protect their server from bad actors? There could be valid reasons for this.
  2. Server admins should be able to protect themselves from known bad actors - E-Mail servers for example have shared (configurable) blacklists.
  3. Can users themselves be enabled to block (?) bad actors? Potentially just for themselves?

All great examples for implementing @Rob-NY RPC firewall.
It doesn't make external calls, currently only blocks single IPs, could potentially be managed by clients directly via RPC.
Any further protection should be handled at the hoster/OS firewall level.

@stefan1000
Copy link

All great examples for implementing @Rob-NY RPC firewall. It doesn't make external calls, currently only blocks single IPs, could potentially be managed by clients directly via RPC. Any further protection should be handled at the hoster/OS firewall level.

A bad actor should not even reach the application, all of this can be done on firewall level (peek into the UDP payload if it is a jamulus client connect msg, then hand it over to some user space script that does further checking)

See e.g. https://tech-champion.com/ethical-hacking/linux-packet-payload-manipulation-netfilter-and-nfqueue-solutions/

@rdica
Copy link
Contributor

rdica commented Jan 21, 2026

A bad actor should not even reach the application, all of this can be done on firewall level (peek into the UDP payload if it is a jamulus client connect msg, then hand it over to some user space script that does further checking)

See e.g. https://tech-champion.com/ethical-hacking/linux-packet-payload-manipulation-netfilter-and-nfqueue-solutions/

While this is certainly one layer of protection, it doesn't address the ability to dynamically block bad actors after a client join. Not all bad actors are known beforehand. The RPC interface could provide that functionality, and wouldn't necessarily require a server operator or client to learn linux, and nft/iptables (or Mac/PF, Windows Firewall).

@stefan1000 Have you tested the RPC firewall?
You make a valid point about bad actors not reaching the application, but I can tell you based on my own testing that once a block has been implemented on the RPC firewall, the bad actor connection is dropped, can no longer see the server in Connect dialog, nor can any attempt to direct connect succeed. Exactly the same behaviour seen when an OS level firewall rule is implemented.

Your suggestion plus the RPC feature could provide a comprehensive level of protection for servers and users on them.

Ultimately I believe in server admin autonomy in dealing with bad actors, and as @softins previously mentioned, if anyone chooses to modify their servers they can do so. I've always advocated inclusion of the RPC firewall code into the core application, but I understand and respect the desire not to do so.

@mcfnord
Copy link
Contributor Author

mcfnord commented Feb 11, 2026

All great examples for implementing @Rob-NY RPC firewall.
It doesn't make external calls, currently only blocks single IPs, could potentially be managed by clients directly via RPC.
Any further protection should be handled at the hoster/OS firewall level.

I know of two actors who harass groups through a VPN that shifts their IP any time they want. I know of zero actors who harass groups through a singular IP address. That's why I think blocking an single IP is inadequate. And these actors target groups on multiple servers, including servers that are unmonitored. I'd like a defense that would protect against much larger attacks, and multi-IP plus unmonitored servers are facts of life any defense of the larger community needs to cover.

@mcfnord
Copy link
Contributor Author

mcfnord commented Feb 11, 2026

  1. Can users themselves be enabled to block (?) bad actors? Potentially just for themselves?

I like the idea of any connection that's mostly-muted (66%+ of other connections?) has their chats silently muted, too.

While anyone is free to create their own fork with modifications to support their use case, I'm not convinced this kind of functionality belongs within Jamulus itself.

Defense and growth of public directory activity isn't everyone's use case, but it's not just my use case! My goal is to provide a custom server until widespread malicious attacks show it's necessary. I know a few server operators who would run a drop-in binary replacement that auto-blocks particular harassers active today. I also know two changes to the client that would improve community discovery, so I'm interested in a fork there, too. I think both long-running, unattended public servers and clients of users active on public servers are two categories that have some unique problems and solutions. Ultimately, I hope to provide these.

@ann0see
Copy link
Member

ann0see commented Feb 11, 2026

I mean technically the App Store guidelines seem to want some moderation features. I hope we'll be able to have client first implementations. This won't harm anyone and empowers users.

@stefan1000
Copy link

All great examples for implementing @Rob-NY RPC firewall.
It doesn't make external calls, currently only blocks single IPs, could potentially be managed by clients directly via RPC.
Any further protection should be handled at the hoster/OS firewall level.

I know of two actors who harass groups through a VPN that shifts their IP any time they want. I know of zero actors who harass groups through a singular IP address. That's why I think blocking an single IP is inadequate. And these actors target groups on multiple servers, including servers that are unmonitored. I'd like a defense that would protect against much larger attacks, and multi-IP plus unmonitored servers are facts of life any defense of the larger community needs to cover.

A jamulus server operator is free to limit access to whatever, just saying this should happen in the network middleware, not in the application.

There a valid use cases for VPNs, also for jamulus, like getting reliable UDP+IPv4 when behind a CGNAT, or avoiding sub-optimal routes because an ISP choose to take a few long latency hops more to not pay for transit.

IP is not an identity, nor is an ASN, it is an ongoing race. If a stronger (or some kind of) user identity is needed, one could require users to authenticate via an OpenID provider (e.g., Google, Apple, Facebook, Amazon, Microsoft) before allowing access.

@ann0see
Copy link
Member

ann0see commented Feb 11, 2026

one could require users to authenticate via an OpenID provider

Something I would rather want to avoid!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants